package com.xingxuecn.demos.service;

import com.xingxuecn.demos.dao.domain.Role;
import com.xingxuecn.demos.dao.domain.RoleExample;
import com.xingxuecn.demos.dao.mapper.RoleMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Kris at 2018/9/28 10:28
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    RoleMapper roleMapper;

    public List<Role> search() {
        RoleExample example = new RoleExample();
        example.setOrderByClause("id desc");
        return roleMapper.selectByExample(example);
    }


    public boolean add(Role role) {
        roleMapper.insertSelective(role);
        return true;
    }

    public boolean update(Role role) {
        roleMapper.updateByPrimaryKeySelective(role);
        return true;
    }

    public Role detail(int id) {
        return roleMapper.selectByPrimaryKey(id);
    }


}
